<template>
  <a-table :columns="columns" :dataSource="dataSource">
    <template #headerCell="obj">
      <div v-if="obj.column.dataIndex === 'name'">当前：{{ obj.title }}</div>
    </template>
    <template #emptyText>没有数据</template>
    <template #bodyCell="obj">
      <div v-if="obj.column.dataIndex === 'methods'">
        <a-button>编辑</a-button>
      </div>
      <div v-if="obj.column.dataIndex === 'age'">年龄：{{ obj.text }}</div>
    </template>
  </a-table>
</template>
<script setup>
const columns = [
  {
    dataIndex: "name",
    title: "姓名",
  },
  {
    dataIndex: "age",
    title: "年龄",
  },
  {
    dataIndex: "methods",
    title: "操作",
  },
];

const dataSource = [
  { name: "小明", age: 30 },
  { name: "小红", age: 32 },
  { name: "小绿", age: 18 },
];
</script>
<style></style>
